package com.ruoyi.bizsys.controller;

import java.util.List;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bizsys.domain.ApplyAppList;
import com.ruoyi.bizsys.service.IApplyAppListService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * appList绑定Controller
 *
 * @author african-loan
 * @date 2021-12-30
 */
@RestController
@RequestMapping("/bizsys/list")
public class ApplyAppListController extends BaseController {
    @Autowired
    private IApplyAppListService applyAppListService;

    /**
     * 查询appList绑定列表
     */
    @PreAuthorize("@ss.hasPermi('bizsys:list:list')")
    @GetMapping("/list")
    public TableDataInfo list(ApplyAppList applyAppList) {
        startPage();
        List<ApplyAppList> list = applyAppListService.selectApplyAppListList(applyAppList);
        return getDataTable(list);
    }

    /**
     * 导出appList绑定列表
     */
    @PreAuthorize("@ss.hasPermi('bizsys:list:export')")
    @Log(title = "appList绑定", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ApplyAppList applyAppList) {
        List<ApplyAppList> list = applyAppListService.selectApplyAppListList(applyAppList);
        ExcelUtil<ApplyAppList> util = new ExcelUtil<ApplyAppList>(ApplyAppList.class);
        return util.exportExcel(list, "list");
    }

    /**
     * 获取appList绑定详细信息
     */
    @PreAuthorize("@ss.hasPermi('bizsys:list:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(applyAppListService.selectApplyAppListById(id));
    }

    /**
     * 新增appList绑定
     */
    @PreAuthorize("@ss.hasPermi('bizsys:list:add')")
    @Log(title = "appList绑定", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ApplyAppList applyAppList) {
        return toAjax(applyAppListService.insertApplyAppList(applyAppList));
    }

    /**
     * 修改appList绑定
     */
    @PreAuthorize("@ss.hasPermi('bizsys:list:edit')")
    @Log(title = "appList绑定", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ApplyAppList applyAppList) {
        return toAjax(applyAppListService.updateApplyAppList(applyAppList));
    }

    /**
     * 删除appList绑定
     */
    @PreAuthorize("@ss.hasPermi('bizsys:list:remove')")
    @Log(title = "appList绑定", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(applyAppListService.deleteApplyAppListByIds(ids));
    }
}
